<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入数量">
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
</body>
<script>
  let num = document.querySelector("input");
  let a = num.value;
  function f(gender) {
    for(let i = 0;i<num.value;i++) {
        let m = document.createElement("img");
      switch (gender) {
        case 1:
          m.src = "1.jpg";
          break;
        case 2:
          m.src = "2.jpg";
          break;
      }
      m.height = 50;
      m.width = 50;
      document.body.append(m);
    }
  }
</script>
</html>